/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Main;

import java.awt.HeadlessException;
import java.awt.event.KeyEvent;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.FontFactory;
import com.itextpdf.text.Image;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import java.awt.FileDialog;
import java.io.File;
import java.io.FileOutputStream;
import java.sql.Date;
import javax.swing.table.DefaultTableModel;
/**
 *
 * @author anas
 */
public class Chercher extends javax.swing.JInternalFrame {

    Connection conn= null;
    ResultSet rs = null;
    PreparedStatement ps =null;
    public Chercher() {
        initComponents();
        conn =gestion_chambes_hotel.Gestion_Chambes_Hotel.DB_Connection();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        chercher = new javax.swing.JLabel();
        chercher_back = new javax.swing.JLabel();
        afficher_tt = new javax.swing.JLabel();
        affiche_tt_back = new javax.swing.JLabel();
        cin = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        Chercher_Client = new javax.swing.JTable();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        Chambre_Client = new javax.swing.JTable();
        chercher_ar = new javax.swing.JLabel();
        Afficher_tout_ar = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();

        setBorder(null);
        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setTitle("                                                                                            Espace Chercher                                                                                                              ");
        setMinimumSize(new java.awt.Dimension(894, 555));
        setPreferredSize(new java.awt.Dimension(894, 555));
        getContentPane().setLayout(null);

        chercher.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        chercher.setForeground(new java.awt.Color(255, 255, 255));
        chercher.setText("Chercher");
        getContentPane().add(chercher);
        chercher.setBounds(380, 10, 100, 40);

        chercher_back.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Buttons/search_.png"))); // NOI18N
        chercher_back.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                chercher_backMouseReleased(evt);
            }
        });
        getContentPane().add(chercher_back);
        chercher_back.setBounds(330, 10, 160, 40);

        afficher_tt.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        afficher_tt.setForeground(new java.awt.Color(255, 255, 255));
        afficher_tt.setText("Afficher tout!");
        getContentPane().add(afficher_tt);
        afficher_tt.setBounds(540, 10, 110, 40);

        affiche_tt_back.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Buttons/afficher_.png"))); // NOI18N
        affiche_tt_back.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                affiche_tt_backMouseReleased(evt);
            }
        });
        getContentPane().add(affiche_tt_back);
        affiche_tt_back.setBounds(500, 10, 160, 40);

        cin.setText("        Entrer le CIN ...");
        cin.setBorder(null);
        cin.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                cinMouseClicked(evt);
            }
        });
        cin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cinActionPerformed(evt);
            }
        });
        cin.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cinKeyPressed(evt);
            }
        });
        getContentPane().add(cin);
        cin.setBounds(50, 20, 180, 30);

        Chercher_Client.setBackground(new java.awt.Color(255, 255, 153));
        Chercher_Client.setFont(new java.awt.Font("Amiri", 1, 12)); // NOI18N
        Chercher_Client.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "CIN", "Nom", "Prenom", "N° Tele", "Email", "Situation", "Metier", "Date de Naissance", "N° Enfants"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        Chercher_Client.setSelectionBackground(new java.awt.Color(0, 153, 204));
        Chercher_Client.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Chercher_ClientMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(Chercher_Client);

        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(0, 70, 892, 210);

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        getContentPane().add(jLabel4);
        jLabel4.setBounds(40, 0, 270, 70);

        Chambre_Client.setBackground(new java.awt.Color(255, 255, 153));
        Chambre_Client.setFont(new java.awt.Font("Amiri", 1, 12)); // NOI18N
        Chambre_Client.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        Chambre_Client.setSelectionBackground(new java.awt.Color(0, 153, 204));
        jScrollPane2.setViewportView(Chambre_Client);

        getContentPane().add(jScrollPane2);
        jScrollPane2.setBounds(3, 280, 890, 240);

        chercher_ar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Buttons/chercher_ar2.png"))); // NOI18N
        getContentPane().add(chercher_ar);
        chercher_ar.setBounds(320, 10, 170, 40);

        Afficher_tout_ar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Buttons/afficher_tout_ar.png"))); // NOI18N
        getContentPane().add(Afficher_tout_ar);
        Afficher_tout_ar.setBounds(491, 10, 160, 40);

        jLabel5.setText("Facture");
        jLabel5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel5MouseClicked(evt);
            }
        });
        getContentPane().add(jLabel5);
        jLabel5.setBounds(690, 10, 110, 40);

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Accueil/wallhaven-19788.jpg"))); // NOI18N
        jLabel3.setText("jLabel3");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(0, 0, 1010, 550);

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
        String data="";
        private DefaultTableModel dt;
        private void SaveID() throws DocumentException  {
                    
             dt=(DefaultTableModel) Chercher_Client.getModel();
             
                        String observation ="" ;
                        String divers="";
                        String adresse="";
                        String vlan="";
                        String inter="";
                        String acheminement="";
                        int type=0;
                        int operation=0;
                        int debit=0;
                        String constitution="";
                        String ville="";
                        String equipement="";
                        String serie="";
                        Date jour_reser=null;
                        Date date_paiement=null;
                        Date der_jour=null;
                        int total_jour=0;
                        int montant=0;
                        String date="";
                        String num="";
                        String nom="";
                        String prenom="";
                        int num_tele=0;
                        int nom_enf=0;
                        int num_reception=0;
                 try{
                    String sql="Select * from client Where CIN_CLIENT=?";
                    PreparedStatement pst=conn.prepareStatement(sql);
                    pst.setString(1,cin.getText());
                    ResultSet res=pst.executeQuery();

                    while (res.next()){
                         num=res.getString("CIN_CLIENT");
                         nom=res.getString("NOM");
                         prenom=res.getString("PRENOM");
                         num_tele=res.getInt("NUMERO_TELE");
                         nom_enf=res.getInt("NOMBRE_ENFANTS");


                    }
              //-----------------------------------------------------------   
                    String sql1="Select * from paiement Where CIN_CLIENT=?";
                    PreparedStatement pst1=conn.prepareStatement(sql1);
                    pst1.setString(1,cin.getText());
                    ResultSet res1=pst1.executeQuery();  

                    while (res1.next()){
                       num_reception=res1.getInt("NUMERO_RECEPTION");
                       jour_reser=res1.getDate("PRE_JOUR_OCCU");
                       date_paiement=res1.getDate("DATE_PAIEMENT");
                       der_jour=res1.getDate("DER_JOUR_OCCU");
                       total_jour=res1.getInt("TOTAL_JOUR");
                       montant=res1.getInt("MONTANT_FACTURE");

                    }
            //--------------------------------------------------------------
                    String sql2="Select * from reservation Where CIN_CLIENT=?";
                    PreparedStatement pst2=conn.prepareStatement(sql2);
                    pst2.setString(1,cin.getText());
                    ResultSet res2=pst2.executeQuery();  

                    while (res2.next()){
                         type=res2.getInt("TYPE_CHAMBRE");
                         operation=res2.getInt("NUM_CHAMBRE");
                         debit=res2.getInt("ETAGE_CHAMBRE");
                         /*constitution=res2.getString("CONSTITUTION");
                         ville=res2.getString("VILLE");
                         equipement=res2.getString("EQUIPEMENT");
                         serie=res2.getString("N_SERIE");*/

                    }
           //--------------------------------------------------------------
                    /*String sql3="Select * from Informations Where N_Client=?";
                    PreparedStatement pst3=conn.prepareStatement(sql3);
                    pst3.setInt(1,Integer.parseInt(dt.getValueAt(i,0).toString()));
                    ResultSet res3=pst3.executeQuery();  

                    while (res3.next()){
                         observation =res3.getString("OBSERVATION");
                         divers=res3.getString("DIVERS");
                         adresse=res3.getString("ADRESSEROUTEUR");
                         vlan=res3.getString("VPI");
                         inter=res3.getString("INTERFACE");
                         acheminement=res3.getString("ACHEMINEMENT");
                         
                    }*/
                }catch(Exception e){
                    JOptionPane.showMessageDialog(null,"Echec SelectInfo "+e.getMessage());
                }
                 try{
               FileDialog dialog=null;
                dialog = new FileDialog (dialog,"Save As PDF",FileDialog.SAVE);
                dialog.show();
               if(dialog.getFile() !=null){
                   data=dialog.getDirectory() + dialog.getFile() +cin.getText()+".pdf";
                   try{
                    File file=new File(data);

                   }catch(Exception e){
                       JOptionPane.showMessageDialog(null,"Echec d'enregistrer PDF "+e.getMessage());
                   }

              Document document=new Document();
              PdfWriter.getInstance(document, new FileOutputStream(data));
              document.open();


               document.bottom(2);
                  Image img=Image.getInstance("/home/anas/NetBeansProjects/Gestion_Chambes_Hotel/src/Main/Images/Accueil/GTeam.png");
                  img.scaleAbsolute(100,70);
                  document.add(new Paragraph("\n"));
                  float[] widt = {0.30f,0.60f,0.10f};
                  PdfPTable tabl=new PdfPTable(widt);
                  tabl.setWidthPercentage(100); 
                  tabl.getDefaultCell().setFixedHeight(40);

                  PdfPCell cl = new PdfPCell(img,false);
                  cl.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl1 = new PdfPCell(new Paragraph("\n \n N° Client : ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.UNDERLINE,BaseColor.BLACK)));  
                  cl1.setHorizontalAlignment(Element.ALIGN_RIGHT);
                  //cl1.setVerticalAlignment(Element.ALIGN_BOTTOM);
                  cl1.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl2 = new PdfPCell(new Paragraph("\n \n "+cin.getText(),FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.RED)));  
                  cl2.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl2.setBorder(Rectangle.NO_BORDER);
                  tabl.addCell(cl);
                  tabl.addCell(cl1);
                  tabl.addCell(cl2);
                  document.add(tabl);

                  float [] widt2={0.30f,0.40f,0.30f};
                  PdfPTable tabl2 = new PdfPTable(widt2);
                  tabl2.setWidthPercentage(100);
                  tabl2.getDefaultCell().setFixedHeight(40);

                  PdfPCell cl3=new PdfPCell(new Paragraph(" ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)) );
                  cl3.setHorizontalAlignment(Element.ALIGN_CENTER);
                  cl3.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl4=new PdfPCell(new Paragraph(""));
                  cl4.setHorizontalAlignment(Element.ALIGN_CENTER);
                  cl4.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl5=new PdfPCell(new Paragraph(""));
                  cl5.setHorizontalAlignment(Element.ALIGN_CENTER);
                  cl5.setBorder(Rectangle.NO_BORDER);
                  tabl2.addCell(cl3);
                  tabl2.addCell(cl4);
                  tabl2.addCell(cl5);
                  document.add(tabl2);
                  document.add(new Paragraph("\n"));

                  float widt3 [] ={0.10f,0.60f,0.30f};
                  PdfPTable tabl3=new  PdfPTable(widt3);
                  tabl3.setWidthPercentage(100);
                  tabl3.getDefaultCell().setFixedHeight(40);

                  PdfPCell cl6=new PdfPCell(new Paragraph("Client : ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl6.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl6.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl7=new PdfPCell(new Paragraph(nom+" "+prenom,FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl7.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl7.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl8=new PdfPCell(new Paragraph("",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl8.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl8.setBorder(Rectangle.NO_BORDER);
                  tabl3.addCell(cl6);
                  tabl3.addCell(cl7);
                  tabl3.addCell(cl8);
                  document.add(tabl3);

                  float widt4 [] ={0.10f,0.60f,0.30f};
                  PdfPTable tabl4=new  PdfPTable(widt4);
                  tabl4.setWidthPercentage(100);
                  tabl4.getDefaultCell().setFixedHeight(40);

                  /*PdfPCell cl41=new PdfPCell(new Paragraph("Contact : ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl41.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl41.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl42=new PdfPCell(new Paragraph(contact+"",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl42.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl42.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl43=new PdfPCell(new Paragraph("",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl43.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl43.setBorder(Rectangle.NO_BORDER);
                  tabl4.addCell(cl41);
                  tabl4.addCell(cl42);
                  tabl4.addCell(cl43);
                  document.add(tabl4);*/


                  float widt5 [] ={0.11f,0.60f,0.29f};
                  PdfPTable tabl5=new  PdfPTable(widt5);
                  tabl5.setWidthPercentage(100);
                  tabl5.getDefaultCell().setFixedHeight(40);

                  PdfPCell cl51=new PdfPCell(new Paragraph("Numéro de réservation : ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl51.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl51.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl52=new PdfPCell(new Paragraph(num_reception+"",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl52.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl52.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl53=new PdfPCell(new Paragraph("",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl53.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl53.setBorder(Rectangle.NO_BORDER);
                  tabl5.addCell(cl51);
                  tabl5.addCell(cl52);
                  tabl5.addCell(cl53);
                  document.add(tabl5);

                  float [] widt6={0.01f,0.98f,0.01f};
                  PdfPTable tabl6 = new PdfPTable(widt6);
                  tabl6.setWidthPercentage(100);
                  tabl6.getDefaultCell().setFixedHeight(40);

                  PdfPCell cl61=new PdfPCell(new Paragraph(" ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)) );
                  cl61.setHorizontalAlignment(Element.ALIGN_CENTER);
                  cl61.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl62=new PdfPCell(new Paragraph("------------------------------------------------------------------------------------------------------------------------"));
                  cl62.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl62.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl63=new PdfPCell(new Paragraph(""));
                  cl63.setHorizontalAlignment(Element.ALIGN_CENTER);
                  cl63.setBorder(Rectangle.NO_BORDER);
                  tabl6.addCell(cl61);
                  tabl6.addCell(cl62);
                  tabl6.addCell(cl63);
                  document.add(tabl6);
                  document.add(new Paragraph("\n"));

                  float widt7 [] ={0.13f,0.81f,0.06f};
                  PdfPTable tabl7=new  PdfPTable(widt7);
                  tabl7.setWidthPercentage(100);
                  tabl7.getDefaultCell().setFixedHeight(40);

                  PdfPCell cl71=new PdfPCell(new Paragraph("Premiére Jour de réservation: ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl71.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl71.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl72=new PdfPCell(new Paragraph(jour_reser+"",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl72.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl72.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl73=new PdfPCell(new Paragraph("",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl73.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl73.setBorder(Rectangle.NO_BORDER);
                  tabl7.addCell(cl71);
                  tabl7.addCell(cl72);
                  tabl7.addCell(cl73);
                  document.add(tabl7);


                  float widt8 [] ={0.13f,0.57f,0.30f};
                  PdfPTable tabl8=new  PdfPTable(widt8);
                  tabl8.setWidthPercentage(100);
                  tabl8.getDefaultCell().setFixedHeight(40);

                  PdfPCell cl81=new PdfPCell(new Paragraph("Date de paiement : ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl81.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl81.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl82=new PdfPCell(new Paragraph(date_paiement+"",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl82.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl82.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl83=new PdfPCell(new Paragraph("",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl83.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl83.setBorder(Rectangle.NO_BORDER);
                  tabl8.addCell(cl81);
                  tabl8.addCell(cl82);
                  tabl8.addCell(cl83);
                  document.add(tabl8);


                  float widt9 [] ={0.12f,0.58f,0.30f};
                  PdfPTable tabl9=new  PdfPTable(widt8);
                  tabl9.setWidthPercentage(100);
                  tabl9.getDefaultCell().setFixedHeight(40);

                  /*PdfPCell cl91=new PdfPCell(new Paragraph("Demande : ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl91.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl91.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl92=new PdfPCell(new Paragraph(demande+"",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl92.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl92.setBorder(Rectangle.NO_BORDER);*/
                  PdfPCell cl93=new PdfPCell(new Paragraph("",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl93.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl93.setBorder(Rectangle.NO_BORDER);
                  //tabl9.addCell(cl91);
                  //tabl9.addCell(cl92);
                  tabl9.addCell(cl93);
                  document.add(tabl9);

                  float widt10 [] ={0.14f,0.57f,0.29f};
                  PdfPTable tabl10=new  PdfPTable(widt10);
                  tabl10.setWidthPercentage(100);
                  tabl10.getDefaultCell().setFixedHeight(40);

                  PdfPCell cl101=new PdfPCell(new Paragraph("Montant : ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl101.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl101.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl102=new PdfPCell(new Paragraph(montant+"",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl102.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl102.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl103=new PdfPCell(new Paragraph("",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl103.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl103.setBorder(Rectangle.NO_BORDER);
                  tabl10.addCell(cl101);
                  tabl10.addCell(cl102);
                  tabl10.addCell(cl103);
                  document.add(tabl10);


                  float [] widtx={0.01f,0.98f,0.01f};
                  PdfPTable tablx = new PdfPTable(widtx);
                  tablx.setWidthPercentage(100);
                  tablx.getDefaultCell().setFixedHeight(40);

                  PdfPCell clx=new PdfPCell(new Paragraph(" ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)) );
                  clx.setHorizontalAlignment(Element.ALIGN_CENTER);
                  clx.setBorder(Rectangle.NO_BORDER);
                  PdfPCell clx1=new PdfPCell(new Paragraph("------------------------------------------------------------------------------------------------------------------------"));
                  clx1.setHorizontalAlignment(Element.ALIGN_LEFT);
                  clx1.setBorder(Rectangle.NO_BORDER);
                  PdfPCell clx2=new PdfPCell(new Paragraph(""));
                  clx2.setHorizontalAlignment(Element.ALIGN_CENTER);
                  clx2.setBorder(Rectangle.NO_BORDER);
                  tablx.addCell(clx);
                  tablx.addCell(clx1);
                  tablx.addCell(clx2);
                  document.add(tablx);
                  document.add(new Paragraph("\n"));


                  float widt11 [] ={0.06f,0.44f,0.06f,0.44f};
                  PdfPTable tabl11=new  PdfPTable(widt11);
                  tabl11.setWidthPercentage(100);
                  tabl11.getDefaultCell().setFixedHeight(40);

                  PdfPCell cl111=new PdfPCell(new Paragraph("Total du jours :",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl111.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl111.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl112=new PdfPCell(new Paragraph(total_jour+"",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl112.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl112.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl113=new PdfPCell(new Paragraph("Etage de Chambre :",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl113.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl113.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl114=new PdfPCell(new Paragraph(debit+"",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl114.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl114.setBorder(Rectangle.NO_BORDER);
                  tabl11.addCell(cl111);
                  tabl11.addCell(cl112);
                  tabl11.addCell(cl113);
                  tabl11.addCell(cl114);
                  document.add(tabl11);




                  float widt13 [] ={0.13f,0.37f,0.10f,0.40f};
                  PdfPTable tabl13=new  PdfPTable(widt13);
                  tabl13.setWidthPercentage(100);
                  tabl13.getDefaultCell().setFixedHeight(40);

                  PdfPCell cl131=new PdfPCell(new Paragraph("Type de Chambre : ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl131.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl131.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl132=new PdfPCell(new Paragraph(type+"",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl132.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl132.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl133=new PdfPCell(new Paragraph("Numero de chambre : ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl133.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl133.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl134=new PdfPCell(new Paragraph(operation+"",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl134.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl134.setBorder(Rectangle.NO_BORDER);
                  tabl13.addCell(cl131);
                  tabl13.addCell(cl132);
                  tabl13.addCell(cl133);
                  tabl13.addCell(cl134);
                  document.add(tabl13);

                  float widt12 [] ={0.15f,0.76f,0.09f};
                  PdfPTable tabl12=new  PdfPTable(widt12);
                  tabl12.setWidthPercentage(100);
                  tabl12.getDefaultCell().setFixedHeight(40);

                  PdfPCell cl121=new PdfPCell(new Paragraph("Derniére Jour de Réservation : ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl121.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl121.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl122=new PdfPCell(new Paragraph(der_jour+"",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl122.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl122.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl123=new PdfPCell(new Paragraph("",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl123.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl123.setBorder(Rectangle.NO_BORDER);
                  tabl12.addCell(cl121);
                  tabl12.addCell(cl122);
                  tabl12.addCell(cl123);
                  document.add(tabl12);

                  float [] widty={0.01f,0.98f,0.01f};
                  PdfPTable tably = new PdfPTable(widty);
                  tably.setWidthPercentage(100);
                  tably.getDefaultCell().setFixedHeight(40);

                  PdfPCell cly=new PdfPCell(new Paragraph(" ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)) );
                  cly.setHorizontalAlignment(Element.ALIGN_CENTER);
                  cly.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cly1=new PdfPCell(new Paragraph("------------------------------------------------------------------------------------------------------------------------"));
                  cly1.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cly1.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cly2=new PdfPCell(new Paragraph(""));
                  cly2.setHorizontalAlignment(Element.ALIGN_CENTER);
                  cly2.setBorder(Rectangle.NO_BORDER);
                  tably.addCell(cly);
                  tably.addCell(cly1);
                  tably.addCell(cly2);
                  document.add(tably);
                  document.add(new Paragraph("\n"));

                  float [] widt14={0.12f,0.38f,0.08f,0.42f};
                  PdfPTable tabl14=new PdfPTable(widt14);
                  tabl14.setWidthPercentage(100);
                  tabl14.getDefaultCell().setFixedHeight(30);

                 /*
                  PdfPCell cl141=new PdfPCell(new Paragraph("Constitution :",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl141.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl141.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl142=new PdfPCell(new Paragraph(constitution,FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl142.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl142.setBorder(Rectangle.NO_BORDER);*/
                  /*PdfPCell cl143=new PdfPCell(new Paragraph("Ville :",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl143.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl143.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl144=new PdfPCell(new Paragraph(ville,FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl144.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl144.setBorder(Rectangle.NO_BORDER);*/
                  /*tabl14.addCell(cl141);
                  tabl14.addCell(cl142);
                  tabl14.addCell(cl143);
                  tabl14.addCell(cl144);
                  document.add(tabl14);*/
                  //document.add(new Paragraph("\n"));  

                  float [] widt15={0.12f,0.38f,0.08f,0.42f};
                  PdfPTable tabl15=new PdfPTable(widt15);
                  tabl15.setWidthPercentage(100);
                  tabl15.getDefaultCell().setFixedHeight(40);

                  /*PdfPCell cl151= new PdfPCell(new Paragraph("Equipement :",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl151.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl151.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl152= new PdfPCell(new Paragraph(equipement,FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl152.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl152.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl153= new PdfPCell(new Paragraph("N°serie :",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl153.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl153.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl154= new PdfPCell(new Paragraph(serie,FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl154.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl154.setBorder(Rectangle.NO_BORDER);
                  tabl15.addCell(cl151);
                  tabl15.addCell(cl152);
                  tabl15.addCell(cl153);
                  tabl15.addCell(cl154);
                  document.add(tabl15);*/

                 /* float [] widtz={0.01f,0.98f,0.01f};
                  PdfPTable tablz = new PdfPTable(widtz);
                  tablz.setWidthPercentage(100);
                  tablz.getDefaultCell().setFixedHeight(40);

                  PdfPCell clz=new PdfPCell(new Paragraph(" ",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)) );
                  clz.setHorizontalAlignment(Element.ALIGN_CENTER);
                  clz.setBorder(Rectangle.NO_BORDER);
                  PdfPCell clz1=new PdfPCell(new Paragraph("------------------------------------------------------------------------------------------------------------------------"));
                  clz1.setHorizontalAlignment(Element.ALIGN_LEFT);
                  clz1.setBorder(Rectangle.NO_BORDER);
                  PdfPCell clz2=new PdfPCell(new Paragraph(""));
                  clz2.setHorizontalAlignment(Element.ALIGN_CENTER);
                  clz2.setBorder(Rectangle.NO_BORDER);
                  tablz.addCell(clz);
                  tablz.addCell(clz1);
                  tablz.addCell(clz2);
                  document.add(tablz);*/
                  //document.add(new Paragraph("\n"));
                  /*
                  float [] widt16={0.12f,0.80f,0.08f};
                  PdfPTable tabl16 = new PdfPTable(widt16);
                  tabl16.setWidthPercentage(100);
                  tabl16.getDefaultCell().setFixedHeight(40);

                  PdfPCell cl161= new PdfPCell(new Paragraph("Observation :",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl161.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl161.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl162= new PdfPCell(new Paragraph(observation,FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl162.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl162.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl163= new PdfPCell(new Paragraph("",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl163.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl163.setBorder(Rectangle.NO_BORDER);
                  tabl16.addCell(cl161);
                  tabl16.addCell(cl162);
                  tabl16.addCell(cl163);
                  document.add(tabl16);

                  float [] widt17={0.08f,0.84f,0.08f};
                  PdfPTable tabl17 = new PdfPTable(widt17);
                  tabl17.setWidthPercentage(100);
                  tabl17.getDefaultCell().setFixedHeight(40);

                  PdfPCell cl171= new PdfPCell(new Paragraph("Divers :",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl171.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl171.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl172= new PdfPCell(new Paragraph(divers,FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl172.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl172.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl173= new PdfPCell(new Paragraph("",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl173.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl173.setBorder(Rectangle.NO_BORDER);
                  tabl17.addCell(cl171);
                  tabl17.addCell(cl172);
                  tabl17.addCell(cl173);
                  document.add(tabl17);

                  float [] widt18={0.14f,0.36f,0.15f,0.35f};
                  PdfPTable tabl18=new PdfPTable(widt18);
                  tabl18.setWidthPercentage(100);
                  tabl18.getDefaultCell().setFixedHeight(40);

                  PdfPCell cl181= new PdfPCell(new Paragraph("VPI/VCI/VLAN :",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl181.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl181.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl182= new PdfPCell(new Paragraph(vlan,FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl182.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl182.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl183= new PdfPCell(new Paragraph("Adresse Routeur :",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl183.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl183.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl184= new PdfPCell(new Paragraph(adresse,FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl184.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl184.setBorder(Rectangle.NO_BORDER);
                  tabl18.addCell(cl181);
                  tabl18.addCell(cl182);
                  tabl18.addCell(cl183);
                  tabl18.addCell(cl184);
                  document.add(tabl18); 

                  float [] widt19={0.09f,0.39f,0.13f,0.37f};
                  PdfPTable tabl19=new PdfPTable(widt19);
                  tabl19.setWidthPercentage(100);
                  tabl19.getDefaultCell().setFixedHeight(40);

                  PdfPCell cl191= new PdfPCell(new Paragraph("Interface :",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl191.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl191.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl192= new PdfPCell(new Paragraph(inter,FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl192.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl192.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl193= new PdfPCell(new Paragraph("Acheminement :",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)));
                  cl193.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl193.setBorder(Rectangle.NO_BORDER);
                  PdfPCell cl194= new PdfPCell(new Paragraph(acheminement,FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.NORMAL,BaseColor.BLACK)));
                  cl194.setHorizontalAlignment(Element.ALIGN_LEFT);
                  cl194.setBorder(Rectangle.NO_BORDER);
                  tabl19.addCell(cl191);
                  tabl19.addCell(cl192);
                  tabl19.addCell(cl193);
                  tabl19.addCell(cl194);
                  document.add(tabl19);*/
                  document.add(new Paragraph("\n"));
                  document.add(new Paragraph("\n"));
                  document.add(new Paragraph("\n"));
                  document.add(new Paragraph("\n"));
                  document.add(new Paragraph("\n"));
                  document.add(new Paragraph("\n"));
                  document.add(new Paragraph("\n"));
                  document.add(new Paragraph("\n"));
                  document.add(new Paragraph("\n"));



                  float [] widtw={0.30f,0.40f,0.30f};
                  PdfPTable tablw = new PdfPTable(widtw);
                  tablw.setWidthPercentage(100);
                  tablw.getDefaultCell().setFixedHeight(40);

                  PdfPCell clw=new PdfPCell(new Paragraph("FPO Génie Logiciel",FontFactory.getFont(FontFactory.TIMES_ROMAN,9,Font.BOLD,BaseColor.BLACK)) );
                  clw.setHorizontalAlignment(Element.ALIGN_CENTER);
                  clw.setBorder(Rectangle.NO_BORDER);
                  PdfPCell clw1=new PdfPCell(new Paragraph("",FontFactory.getFont(FontFactory.TIMES_ROMAN,10,Font.BOLD,BaseColor.BLACK) ));
                  clw1.setHorizontalAlignment(Element.ALIGN_CENTER);
                  clw1.setBorder(Rectangle.NO_BORDER);
                  PdfPCell clw2=new PdfPCell(new Paragraph("Signature: ...........",FontFactory.getFont(FontFactory.TIMES_ROMAN,10,Font.BOLD,BaseColor.BLACK)));
                  clw2.setHorizontalAlignment(Element.ALIGN_CENTER);
                  clw2.setBorder(Rectangle.NO_BORDER);
                  tablw.addCell(clw);
                  tablw.addCell(clw1);
                  tablw.addCell(clw2);
                  document.add(tablw);
                  document.add(new Paragraph("\n"));




              document.close();
               JOptionPane.showMessageDialog(null,"document a ete Enregistrer ");    
               }
                 }catch(Exception e){
                     JOptionPane.showMessageDialog(null,"document n'a pas ete Enregistrer ! "+e.getMessage());
                 }
              // end of first try
             }


    
    
    
    
    
    public void Traduire()
    {
            chercher.setText("بحت");
            afficher_tt.setText("عرض الكل");
            cin.setText("ادخل الرقم الوطني");
            chercher_back.setVisible(false);
            chercher.setVisible(false);
            affiche_tt_back.setVisible(false);
            afficher_tt.setVisible(false);
            chercher_ar.setVisible(true);
            Afficher_tout_ar.setVisible(true);
    }
    public void Visibility()
        {
            chercher_ar.setVisible(false);
            Afficher_tout_ar.setVisible(false);
        
        }
      private void Update_Table(){
            
        try{
            String sql="SELECT * FROM client";
            String sql_chambre="SELECT CIN_CLIENT,NUM_CHAMBRE,TYPE_CHAMBRE,ETAGE_CHAMBRE FROM reservation";
            
            
            ps = conn.prepareStatement(sql);
            PreparedStatement ps_ch=conn.prepareStatement(sql_chambre);
            
            ResultSet rs_ch=null;
            
            rs=ps.executeQuery();
            rs_ch=ps_ch.executeQuery();
            
            Chercher_Client.setModel(DbUtils.resultSetToTableModel(rs));
            Chambre_Client.setModel(DbUtils.resultSetToTableModel(rs_ch));
        }
        catch(SQLException e){
            
            JOptionPane.showMessageDialog(null,e);
        }
        
    }
    
    private void chercher() 
    {
            
            String CIN =cin.getText();
            try{
                
                if(CIN.equals(""))
                    {
                        JOptionPane.showMessageDialog(null, "Entrer un CIN s'il vous plaît !");
                    }
                else
                    {
                        String sql1="SELECT * FROM client where CIN_CLIENT='"+CIN+"'";
                        PreparedStatement ps1 = conn.prepareStatement(sql1);
                        
                        ResultSet rs1=ps1.executeQuery();
                        if(rs1.next()){
                            
                            rs1=ps1.executeQuery();
                            Chercher_Client.setModel(DbUtils.resultSetToTableModel(rs1));
                            
                        }
                        else{
                            JOptionPane.showMessageDialog(null, "Ce CIN n'existe pas .. essayer avec un autre!");
                        }
                }
            }
            catch(HeadlessException | SQLException e){
            
                JOptionPane.showMessageDialog(null, e.getMessage());
            }
            
    }
    
    private void chercher_chambre() 
    {
            
            String CIN =cin.getText();
            try{
                
                if(CIN.equals(""))
                    {
                        JOptionPane.showMessageDialog(null, "Entrer un CIN s'il vous plaît !");
                    }
                else
                    {
                        String sql1="SELECT CIN_CLIENT,NUM_CHAMBRE,TYPE_CHAMBRE,ETAGE_CHAMBRE FROM reservation where CIN_CLIENT='"+CIN+"'";
                        PreparedStatement ps1 = conn.prepareStatement(sql1);
                        
                        ResultSet rs1=ps1.executeQuery();
                        if(rs1.next()){
                            
                            rs1=ps1.executeQuery();
                            Chambre_Client.setModel(DbUtils.resultSetToTableModel(rs1));
                            
                        }
                        else{
                            //JOptionPane.showMessageDialog(null, "Ce CIN n'existe pas .. essayer avec une autre!");
                        }
                }
            }
            catch(HeadlessException | SQLException e){
            
                JOptionPane.showMessageDialog(null, e.getMessage());
            }
            
    }
    
    
    
    private void cinActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cinActionPerformed
       
    }//GEN-LAST:event_cinActionPerformed
    
    private void chercher_backMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_chercher_backMouseReleased
        
        chercher_chambre();
        chercher();
        
            
    }//GEN-LAST:event_chercher_backMouseReleased

    private void affiche_tt_backMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_affiche_tt_backMouseReleased
        
        Update_Table();
        
    }//GEN-LAST:event_affiche_tt_backMouseReleased

    private void cinMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cinMouseClicked
       cin.setText("");
    }//GEN-LAST:event_cinMouseClicked

    private void cinKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cinKeyPressed
        
         if(evt.getKeyCode()==KeyEvent.VK_ENTER){
            chercher();
            chercher_chambre();
        }
               
    }//GEN-LAST:event_cinKeyPressed
    int i=0;
    private void Chercher_ClientMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Chercher_ClientMouseClicked
            try{
                
                i=Chercher_Client.getSelectedRow();
                
               }catch(Exception e){
                 JOptionPane.showMessageDialog(null,"Echec de Deplacer ! "+e.getMessage()); 
            }
        try {
            
            int row =Chercher_Client.getSelectedRow();
            String Table_click=(Chercher_Client.getModel().getValueAt(row, 0).toString());
            
            String sql0="select * from client where CIN_CLIENT='"+Table_click+"'";
            
            PreparedStatement ps0 = conn.prepareStatement(sql0);
            rs=ps0.executeQuery();
            
            
            if(rs.next())
            {
                String num=rs.getString("CIN_CLIENT");
                cin.setText(num);
            
            }
            
        } catch (Exception e) {
            
                JOptionPane.showInternalMessageDialog(null,e.getMessage());
            
        }
    }//GEN-LAST:event_Chercher_ClientMouseClicked

    private void jLabel5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel5MouseClicked
        try {
            SaveID();
        } catch (DocumentException ex) {
            Logger.getLogger(Chercher.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jLabel5MouseClicked
    
    public void Details()
    {   
            
    
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Afficher_tout_ar;
    private javax.swing.JTable Chambre_Client;
    private javax.swing.JTable Chercher_Client;
    private javax.swing.JLabel affiche_tt_back;
    private javax.swing.JLabel afficher_tt;
    private javax.swing.JLabel chercher;
    private javax.swing.JLabel chercher_ar;
    private javax.swing.JLabel chercher_back;
    private javax.swing.JTextField cin;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    // End of variables declaration//GEN-END:variables
}
